#include <iostream>

using namespace std;

void swap(int& a, int& b) {
	int temp = a;
	a = b;
	b = temp;
}

int main() {
	int** numArray;
	numArray = new int* [3];
	for (int rowId = 0; rowId < 3; rowId++) {
		numArray[rowId] = new int[3];
		for (int columnId = 0; columnId < 3; columnId++) {
			cin >> numArray[rowId][columnId];
		}
	}
	cout << "初始矩阵：" << endl;
	for (int rowId = 0; rowId < 3; rowId++) {
		for (int columnId = 0; columnId < 3; columnId++) {
			cout << numArray[rowId][columnId] << ' ';
		}
		cout << endl;
	}
	for (int rowId = 0; rowId < 3; rowId++) {
		for (int columnId = rowId + 1; columnId < 3; columnId++) {
			swap(numArray[rowId][columnId], numArray[columnId][rowId]);
		}
	}
	cout << "最终矩阵：" << endl;
	for (int rowId = 0; rowId < 3; rowId++) {
		for (int columnId = 0; columnId < 3; columnId++) {
			cout << numArray[rowId][columnId] << ' ';
		}
		cout << endl;
	}
	return 0;
}
